<?php
/**
 * ActiveRecordLog Model Class File
 *
 * @package
 * @author
 */

/**
 * This is the model class for table "{{activerecordlog}}".
 *
 * The followings are the available columns in table '{{activerecordlog}}':
 * @property integer $id
 * @property string $modelName
 * @property string $actionName
 * @property integer $recordId
 * @property string $userIdCreated
 * @property integer $timestampCreated
 *
 * @package
 * @author
 */
class ActiveRecordLog extends MyModel
{
    // {{{ *** Members ***

    /**
     * List of fields composing the record name (separated by ;)
     * @var string
     */
    var $nameFields = "id";

    /**
     * Name format string (e.g. '{1} (#{2})' 
     * @var string
     */
    var $nameFormat = "{1}";
    
    /**
     * Does this model use record revisions?
     * @var bool
     */
    var $usesRevision   = false;

    /**
     * Revision number of current record
     * @var int
     */
    var $recordRevision;

    /**
     * Does this model use logging?
     * @var bool
     */
    var $usesLog        = false;

    Const ACTION_CREATE = 'CREATE';
    Const ACTION_CHANGE = 'CHANGE';
    Const ACTION_DELETE = 'DELETE';

    // }}} 
    // {{{ *** Methods ***
    // {{{ model
    /**
     * Returns the static model of the specified AR class.
     * @return ActiveRecordLog the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    } // }}} 
    // {{{ tableName
    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return '{{activerecordlog}}';
    } // }}} 
    // {{{ rules
    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('recordId, userId, timestamp', 'numerical', 'integerOnly'=>true),
            array('modelName, fieldName', 'length', 'max'=>45),
            array('action', 'length', 'max'=>20),
            array('description','required'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, modelName, action, recordId, userId, timestamp, description', 'safe', 'on'=>'search'),
        );
    } // }}} 
    // {{{ relations
    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'user' => array(self::BELONGS_TO,'User','userId'),
        );
    } // }}} 
    // {{{ attributeLabels
    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => Yii::t('site','ID'),
            'modelName' => Yii::t('site','Model Name'),
            'recordId' => Yii::t('site','Record ID'),
            'action' => Yii::t('site','Action'),
            'userId' => Yii::t('site','User'),
            'timestamp' => Yii::t('site','Timestamp'),
        );
    } // }}} 
    // {{{ search
    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;
        $criteria->order = 'timestamp DESC';

        $criteria->compare('id',$this->id);
        $criteria->compare('modelName',$this->modelName,true);
        $criteria->compare('recordId',$this->recordId);
        $criteria->compare('action',$this->action,true);
        $criteria->compare('userId',$this->userId,true);
        $criteria->compare('timestamp',$this->timestamp);
        $criteria->compare('description',$this->description);
        
        return new CActiveDataProvider(get_class($this), array('criteria'=>$criteria));
    } // }}} 
    // {{{ getActionOptions
    /**
     * Returns an array of action => action name options
     * 
     * @access public
     * @return array
     */
    public function getActionOptions()
    {
        return array(
            self::ACTION_CREATE => Yii::t('site','Create'),
            self::ACTION_CHANGE => Yii::t('site','Change'),
            self::ACTION_DELETE => Yii::t('site','Delete'),
        );
    } // }}} 
    // }}} 
}

/* vim: set ai sw=4 sts=4 et fdm=marker fdc=4 */ 
?>
